//
//  GHMerchantInputController.m
//  GodHorses
//
//  Created by Mac on 2017/11/22.
//  Copyright © 2017年 stoneobs@icloud.com. All rights reserved.
//

#import "GHMerchantInputController.h"
#import "STTextView.h"
#import "STTableViewDetailController.h"
#define buttonHeight  80
@interface GHMerchantInputController ()
@property(nonatomic, strong) NSArray<NSArray*>            *dataSouce;
@property(nonatomic, strong) STButton                     *licenseButton;//执照
@property(nonatomic, strong) STButton                     *headButton;//门头图
@property(nonatomic, strong) STButton                     *goodButton;//商品按钮
@property(nonatomic, strong) UIView                       *cardView;
@property(nonatomic, strong) STButton                     *cardButton;//身份证
@property(nonatomic, strong) STButton                     *cardBackButton;//身份证背面
@property(nonatomic, strong) NSMutableArray               *goodButtonsArray;//imageAgrray
@property(nonatomic, strong) STTextView                   *textView;
@property(nonatomic, strong) UIImage                      *originmage ;

@property(nonatomic, strong) NSString                     *addr_s;
@property(nonatomic, strong) NSString                     *addr_c;
@property(nonatomic, strong) NSString                     *addr_d;
#pragma mark --url
@property(nonatomic, strong) NSString                     *licenseUrlString;
@property(nonatomic, strong) NSString                     *headUrlString;
@property(nonatomic, strong) NSString                     *cardUrlString;
@property(nonatomic, strong) NSString                     *cardBackUrlString;
@property(nonatomic, strong) NSMutableArray               *goodsUrlArray;

@end

@implementation GHMerchantInputController
- (void)dealloc{
    NSLog(@"GHMerchantInputController dealloc");
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"商家入驻";
     self.originmage = [UIImage imageNamed:@"sz_xiangce"];
    self.goodButtonsArray = [NSMutableArray new];
    [self configSubView];
    [self configTableFooter];
    [self configDataSouce];
   
    // Do any additional setup after loading the view.
}
- (STButton*)defultButton{
    STButton * button = [[STButton alloc] initWithFrame:CGRectMake(0, 0, buttonHeight, buttonHeight)
                                                  title:@""
                                             titleColor:GH_thirdTextColor
                                              titleFont:14
                                           cornerRadius:0
                                        backgroundColor:GH_backgroundColor
                                        backgroundImage:nil
                                                  image:_originmage];
    button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    // button.titleEdgeInsets = UIEdgeInsetsMake(0, -button.imageView.size.width, button.imageView.size.height, 0);
    return button;
}
- (void)configSubView{
    
    self.licenseButton = [self defultButton];
    self.headButton = [self defultButton];
    self.goodButton = [self defultButton];
    self.cardView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, buttonHeight * 2 + 10, buttonHeight)];
    self.cardButton = [self defultButton];
    self.cardBackButton = [self defultButton];
    [self.cardView addSubview:self.cardButton];
    [self.cardView addSubview:self.cardBackButton];
    self.cardBackButton.left = self.cardBackButton.width + 10;
    self.cardBackButton.top = 5;
    self.cardButton.top = 5;
    
    __weak typeof(self) weakSelf =  self;
    [self.licenseButton setClicAction:^(UIButton *sender) {
        [weakSelf onSelectedLisnsesButton];
    }];
    [self.headButton setClicAction:^(UIButton *sender) {
        [weakSelf onSelectedheadButton];
    }];
    [self.goodButton setClicAction:^(UIButton *sender) {
        [weakSelf onSelectedGoodsButton];
    }];
    [self.cardButton setClicAction:^(UIButton *sender) {
        [weakSelf onSelectedcardButton];
    }];
    [self.cardBackButton setClicAction:^(UIButton *sender) {
        [weakSelf onSelectedBackCardButton];
    }];
}
- (void)configDataSouce{
    GHTableEasyModel * linsensModel = [[GHTableEasyModel alloc] initWithTextString:@"上传营业执照" accessoryView:self.licenseButton];
    linsensModel.height = buttonHeight + 10;
    
    GHTableEasyModel * headModel = [[GHTableEasyModel alloc] initWithTextString:@"上传门头图" accessoryView:self.headButton];
    headModel.height = buttonHeight + 10;
    
    GHTableEasyModel * goodModel =  [[GHTableEasyModel alloc] initWithTextString:@"上传店铺商品图" accessoryView:self.goodButton];
    goodModel.height = buttonHeight + 10;
    
    NSArray * sectionOne =@[
                            [[GHTableEasyModel alloc] initWithTextString:@"店铺名称" detailString:@""],
                            [[GHTableEasyModel alloc] initWithTextString:@"公司名称" detailString:@""],
                            [[GHTableEasyModel alloc] initWithTextString:@"店铺地址" detailString:@""],
                            [[GHTableEasyModel alloc] initWithTextString:@"店铺类型" detailString:@""],
                            [[GHTableEasyModel alloc] initWithTextString:@"详细地址" detailString:@""],
                            [[GHTableEasyModel alloc] initWithTextString:@"店铺手机号" detailString:@""],
                            linsensModel,
                            headModel,
                            goodModel
                            ];
    
    GHTableEasyModel * cardModel =  [[GHTableEasyModel alloc] initWithTextString:@"上传身份证"
                                                                   accessoryView:self.cardView];
    cardModel.height = buttonHeight;
    NSArray * sectionTwo = @[cardModel,
                             ];
    self.dataSouce = @[sectionOne,sectionTwo];
    [self.tableView reloadData];
}
- (void)configTableFooter{
    __weak typeof(self) weakSelf =  self;
    UIView * footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 100)];
    footer.backgroundColor = self.tableView.backgroundColor;
    UIView * whiteView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 200)];
    whiteView.backgroundColor = [UIColor whiteColor];
    [footer addSubview:whiteView];
    STLabel * titleLable = [[STLabel alloc] initWithFrame:CGRectMake(self.insetX, 0, UIScreenWidth - 30, 40)
                                                     text:@"店铺介绍"
                                                textColor:GH_firstTextColor
                                                     font:14
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    [whiteView addSubview:titleLable];
    self.textView = [[STTextView alloc] initWithFrame:CGRectMake(15, titleLable.bottom + 0, UIScreenWidth - 30, 150)];
    self.textView.placeholder = @"请输入店铺介绍";
    self.textView.textColor = GH_firstTextColor;
    self.textView.font = [UIFont systemFontOfSize:14];
    [whiteView addSubview:self.textView];
    whiteView.height = self.textView.bottom + 10;
    
    STButton * confimButton = [[STButton alloc] initWithFrame:CGRectMake(30, whiteView.bottom + 20, UIScreenWidth - 60, 44)
                                                        title:@"提交"
                                                   titleColor:GH_YellowBackGroundColor
                                                    titleFont:18
                                                 cornerRadius:5
                                              backgroundColor:GH_BlackBackGroundColor
                                              backgroundImage:nil
                                                        image:nil];
    [confimButton setClicAction:^(UIButton *sender) {
        [weakSelf onSelectedCommitButton];
    }];
    confimButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    [footer addSubview:confimButton];
    footer.height = confimButton.bottom + 20;
    self.tableView.tableFooterView = footer;
}
#pragma --mark UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return self.dataSouce.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.dataSouce[section].count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    GHTableEasyModel * model = self.dataSouce[indexPath.section][indexPath.row];
    return model.height;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return 0.01;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    if (section == 0) {
        if (self.goodButtonsArray.count == 0) {
            return  0.01;
        }
        CGFloat witdh = (UIScreenWidth - 60)/5;
        CGFloat height = witdh + 10;
        NSInteger num = ( self.goodButtonsArray.count / 5) + 1;
        return height * num;
    }
    return 0.01;
}
- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return [UIView new];
}
- (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    if (section == 0) {
        CGFloat witdh = (UIScreenWidth - 60)/5;
        CGFloat height = witdh * 10;
        NSInteger num = ( self.goodButtonsArray.count / 5) + 1;
        CGFloat finshHeght =  height * num;
        UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, finshHeght)];
        view.backgroundColor = [UIColor whiteColor];
        for (int i = 0; i< self.goodButtonsArray.count; i++) {
            STButton * buyButton = [[STButton alloc] initWithFrame:CGRectMake(10 * (i%5+ 1) + witdh * (i%5), 5 + i/5 * witdh + 5 * (i/5), witdh , witdh)
                                                             title:@""
                                                        titleColor:nil
                                                         titleFont:0
                                                      cornerRadius:0
                                                   backgroundColor:self.tableView.backgroundColor
                                                   backgroundImage:self.goodButtonsArray[i]
                                                             image:nil];
            [view addSubview:buyButton];
        }
        return view;
    }
    return [UIView new];
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NSString * reuseIdentifier = [NSString stringWithFormat:@"%ld",indexPath.row];
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseIdentifier];
        
    }
    cell.textLabel.textColor = UIColorFromRGBA(0x333333);
    cell.textLabel.font = [UIFont systemFontOfSize:14];
    cell.detailTextLabel.font = [UIFont systemFontOfSize:13];
    cell.detailTextLabel.textColor = UIColorFromRGBA(0x999999);
    GHTableEasyModel * model = self.dataSouce[indexPath.section][indexPath.row];
    
    cell.textLabel.text = model.textString;
    cell.detailTextLabel.text = model.detailString;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if (model.accessoryView) {
        cell.accessoryView = model.accessoryView;
    }else{
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    return cell;
}
#pragma --mark UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    GHTableEasyModel * model = self.dataSouce[indexPath.section][indexPath.row];
    if (indexPath.section == 0 && indexPath.row == 0 ) {
        [self onSelectedShopNameCellWithModel:model indexPath:indexPath];
    }
    if (indexPath.section == 0 && indexPath.row == 1 ) {
        [self onSelectedCompanyNameCellWithModel:model indexPath:indexPath];
    }
    if (indexPath.section == 0 && indexPath.row == 2 ) {
        [self onSelectedCompanyAddCellWithModel:model indexPath:indexPath];
    }
    if (indexPath.section == 0 && indexPath.row == 3 ) {
        [self onSelectedCompanyTypeCellWithModel:model indexPath:indexPath];
    }
    if (indexPath.section == 0 && indexPath.row == 4 ) {
        [self onSelectedCompanyDetailAddCellWithModel:model indexPath:indexPath];
    }
    if (indexPath.section == 0 && indexPath.row == 5 ) {
        [self onSelectedphoneCellWithModel:model indexPath:indexPath];
    }
    [self.tableView deselectRowAtIndexPath:indexPath animated:NO];
}
#pragma mark --cell Action Method
//店铺名字
- (void)onSelectedShopNameCellWithModel:(GHTableEasyModel*)model indexPath:(NSIndexPath*)indexPath{
    
    STTableViewDetailController * vc =
    [[STTableViewDetailController alloc] initWithPlaceholder:@"请输入店铺名"
                                                       title:model.textString
                                                        text:model.detailString
                                                      handle:^(NSString *text) {
                                                          model.detailString = text;
                                                          [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
                                                          [self.navigationController popViewControllerAnimated:YES];
                                                      }];
    [self.navigationController pushViewController:vc animated:YES];
}
//公司名字
- (void)onSelectedCompanyNameCellWithModel:(GHTableEasyModel*)model indexPath:(NSIndexPath*)indexPath{
    STTableViewDetailController * vc =
    [[STTableViewDetailController alloc] initWithPlaceholder:@"请输入公司名字"
                                                       title:model.textString
                                                        text:model.detailString
                                                      handle:^(NSString *text) {
                                                          model.detailString = text;
                                                          [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
                                                          [self.navigationController popViewControllerAnimated:YES];
                                                      }];
    [self.navigationController pushViewController:vc animated:YES];
}
//店铺地址
- (void)onSelectedCompanyAddCellWithModel:(GHTableEasyModel*)model indexPath:(NSIndexPath*)indexPath{
    
    STPickerViewController * vc = [[STPickerViewController alloc] initWithDefualtAreaPickerWithHandle:^(NSString *finshString, NSString *area, NSString *city, NSString *provence) {
        model.detailString = [NSString stringWithFormat:@"%@%@",provence,city];
        self.addr_s = provence;
        self.addr_c = city;
        self.addr_d = @" ";
      [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    }];
    vc.confimTitleColor = GH_YellowBackGroundColor;
    [self presentViewController:vc animated:NO completion:nil];
}
//店铺类型
- (void)onSelectedCompanyTypeCellWithModel:(GHTableEasyModel*)model indexPath:(NSIndexPath*)indexPath{
    STTableViewDetailController * vc =
    [[STTableViewDetailController alloc] initWithPlaceholder:@"请输入店铺类型"
                                                       title:model.textString
                                                        text:model.detailString
                                                      handle:^(NSString *text) {
                                                          model.detailString = text;
                                                          [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
                                                          [self.navigationController popViewControllerAnimated:YES];
                                                      }];
    [self.navigationController pushViewController:vc animated:YES];
}
//详细地址
- (void)onSelectedCompanyDetailAddCellWithModel:(GHTableEasyModel*)model indexPath:(NSIndexPath*)indexPath{
    STTableViewDetailController * vc =
    [[STTableViewDetailController alloc] initWithPlaceholder:@"请输入店铺详细地址"
                                                       title:model.textString
                                                        text:model.detailString
                                                      handle:^(NSString *text) {
                                                          model.detailString = text;
                                                          [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
                                                          [self.navigationController popViewControllerAnimated:YES];
                                                      }];
    [self.navigationController pushViewController:vc animated:YES];
}
//手机号
- (void)onSelectedphoneCellWithModel:(GHTableEasyModel*)model indexPath:(NSIndexPath*)indexPath{
    STTableViewDetailController * vc =
    [[STTableViewDetailController alloc] initWithPlaceholder:@"请输入店铺手机号"
                                                       title:model.textString
                                                        text:model.detailString
                                                      handle:^(NSString *text) {
                                                          model.detailString = text;
                                                          [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
                                                          [self.navigationController popViewControllerAnimated:YES];
                                                      }];
    vc.textFiled.keyboardType = UIKeyboardTypeNumberPad;
    [self.navigationController pushViewController:vc animated:YES];
}
#pragma mark --button Action Method
- (void)onSelectedCommitButton{

    //判断输入值
    for (int i = 0; i < 6; i ++) {
      GHTableEasyModel * model0 = self.dataSouce[0][i];
        if (!model0.detailString.length) {
            [SVProgressHUD showErrorWithStatus:[NSString stringWithFormat:@"请输入%@",model0.textString]];
            return;
        }
    }
    //判断图片
    if (self.licenseButton.currentImage == _originmage) {
        [SVProgressHUD showErrorWithStatus:@"请上传营业执照照片"];
        return;
    }
    if (self.headButton.currentImage == _originmage) {
        [SVProgressHUD showErrorWithStatus:@"请上传门店头照片"];
        return;
    }
    if (self.goodButtonsArray.count == 0) {
        [SVProgressHUD showErrorWithStatus:@"请上传商品照片"];
        return;
    }
    if (self.cardButton.currentImage == _originmage) {
        [SVProgressHUD showErrorWithStatus:@"请上传身份证照片"];
        return;
    }
    if (self.cardBackButton.currentImage == _originmage) {
        [SVProgressHUD showErrorWithStatus:@"请上传身份证背面照片"];
        return;
    }
    if (!self.textView.text.length) {
        [SVProgressHUD showErrorWithStatus:@"请输入店铺介绍"];
        return;
    }

    [self sendImagesrequest];
}
//营业执照
- (void)onSelectedLisnsesButton{
    [self showDefultImagePicker:^(UIImage *image) {
        [self.licenseButton setImage:image forState:UIControlStateNormal];
    }];
}
//门头图
- (void)onSelectedheadButton{
    [self showDefultImagePicker:^(UIImage *image) {
        [self.headButton setImage:image forState:UIControlStateNormal];
    }];
}
//商品图
- (void)onSelectedGoodsButton{
    
    [self showSTImagePickerHandle:^(NSArray<STPhotoModel *> *array) {
        for (STPhotoModel * model in array) {
            [self.goodButtonsArray addObject:model.thumbImage];
        }
        [self.tableView reloadData];
        
    } pickerBlock:^(UIImage *image) {
        
    }];
}
//身份证
- (void)onSelectedcardButton{
    [self showDefultImagePicker:^(UIImage *image) {
        [self.cardButton setImage:image forState:UIControlStateNormal];
    }];
}
//身份证背面
- (void)onSelectedBackCardButton{
    [self showDefultImagePicker:^(UIImage *image) {
        [self.cardBackButton setImage:image forState:UIControlStateNormal];
    }];
}
#pragma mark --Private Method
- (BOOL)isAllImagesUpload{
    BOOL goodUplod = (self.goodButtonsArray.count == self.goodsUrlArray.count);
    BOOL forUpdate = (self.licenseUrlString.length && self.headUrlString.length  &&
                      self.cardUrlString.length && self.cardBackUrlString.length);
    BOOL allUpload = (goodUplod && forUpdate);
    return allUpload;
}
#pragma mark --NetWork Method
- (void)sendImagesrequest{

    [SVProgressHUD showWithStatus:@"上传中"];
    [self sendOneImageRequestWithName:@"file" image:self.licenseButton.currentImage handle:^(NSString *url) {
        self.licenseUrlString = url;
    }];
    [self sendOneImageRequestWithName:@"file" image:self.headButton.currentImage handle:^(NSString *url) {
        self.headUrlString = url;
    }];
    [self sendOneImageRequestWithName:@"file" image:self.cardBackButton.currentImage handle:^(NSString *url) {
        self.cardUrlString = url;
    }];
    [self sendOneImageRequestWithName:@"file" image:self.cardBackButton.currentImage handle:^(NSString *url) {
        self.cardBackUrlString = url;
    }];
    self.goodsUrlArray = [NSMutableArray new];
    for (UIImage * image in self.goodButtonsArray) {
        [self sendOneImageRequestWithName:@"file" image:image handle:^(NSString *url) {
            [self.goodsUrlArray addObject:url];
        }];
    }
}
- (void)sendOneImageRequestWithName:(NSString*)name image:(UIImage*)image handle:(void(^)(NSString * url))handle{

    NSMutableDictionary * dic = [NSMutableDictionary new];
    if ([GHUserManger defult].userID.length) {
        [dic setObject:[GHUserManger defult].userID forKey:@"uid"];
    }
    if ([GHUserManger defult].token.length) {
        [dic setObject:[GHUserManger defult].token forKey:@"token"];
    }
    [[STNetWrokManger defaultClient] imageRequestWithPath:@"http://test.smqyp.com/Api/index/upload_img"
                                               parameters:dic
                                                    image:image
                                                imageName:name
                                                 progress:^(NSProgress *progress) {
                                                     
                                                 } success:^(NSURLSessionDataTask *operation, id responseObject) {
                                                     NSDictionary * data = responseObject[@"data"];
                                                     if ([data.allKeys containsObject:@"up_pic_url"]) {
                                                         NSString * url = data[@"up_pic_url"];
                                                         if (handle) {
                                                             handle(url);
                                                         }
                                                     }
                                                     BOOL allUpload = [self isAllImagesUpload];
                                                     if (allUpload) {
                                                         [self sendUploadshopRequest];
                                                         NSLog(@"所有图片上传成功");
                                                     }
                                                 } failure:^(NSString *stateCode, STError *error) {
                                                     [SVProgressHUD showErrorWithStatus:@"一张图片上传失败"];
                                                 }];
}

- (void)sendUploadshopRequest{

    NSMutableDictionary * dic = [NSMutableDictionary new];
    if ([GHUserManger defult].userID.length) {
        [dic setObject:[GHUserManger defult].userID forKey:@"uid"];
    }
    if ([GHUserManger defult].token.length) {
        [dic setObject:[GHUserManger defult].token forKey:@"token"];
    }
    GHTableEasyModel * model0 = self.dataSouce.firstObject[0];
    if (model0.detailString.length) {
        [dic setObject:model0.detailString forKey:@"shop_name"];
    }
    GHTableEasyModel * model1 = self.dataSouce.firstObject[1];
    if (model1.detailString.length) {
        [dic setObject:model1.detailString forKey:@"company_name"];
    }
    GHTableEasyModel * model2 = self.dataSouce.firstObject[2];
    if (model2.detailString.length) {
        [dic setObject:self.addr_s.length?self.addr_s:@"" forKey:@"addr_s"];
        [dic setObject:self.addr_c.length?self.addr_c:@"" forKey:@"addr_c"];
        [dic setObject:self.addr_d.length?self.addr_d:@" " forKey:@"addr_d"];
    }
    GHTableEasyModel * model3 = self.dataSouce.firstObject[3];
    if (model3.detailString.length) {
        [dic setObject:model3.detailString forKey:@"shop_type"];
    }
    GHTableEasyModel * model4 = self.dataSouce.firstObject[4];
    if (model4.detailString.length) {
        [dic setObject:model4.detailString forKey:@"addr_info"];
    }
    GHTableEasyModel * model5 = self.dataSouce.firstObject[5];
    if (model5.detailString.length) {
        [dic setObject:model5.detailString forKey:@"shop_phone"];
    }
    if (self.licenseUrlString.length) {
         [dic setObject:self.licenseUrlString forKey:@"license"];
    }
    if (self.headUrlString.length) {
        [dic setObject:self.headUrlString forKey:@"logo"];
    }
    if (self.goodsUrlArray.count) {
        NSString *urls = [self.goodsUrlArray componentsJoinedByString:@","];
        [dic setObject:urls forKey:@"photo"];
    }
    if (self.cardUrlString.length) {
        [dic setObject:self.cardUrlString forKey:@"card_z"];
    }
    if (self.cardBackUrlString.length) {
        [dic setObject:self.cardBackUrlString forKey:@"card_b"];
    }
    if (self.textView.text.length) {
        [dic setObject:self.textView.text forKey:@"shop_info"];
    }
    [[STNetWrokManger defaultClient] requestWithPath:@"http://test.smqyp.com/Api/index/shop_settled"
                                              method:STHttpRequestTypePost
                                          parameters:dic
                                             success:^(NSURLSessionDataTask *operation, id responseObject) {
                                                 [SVProgressHUD dismiss];
                                                 [SVProgressHUD showSuccessWithStatus:@"上传成功"];
                                                 [self.navigationController popViewControllerAnimated:YES];
                                                 
                                             } failure:^(NSString *stateCode, STError *error) {
                                                 [SVProgressHUD dismiss];
                                                 [SVProgressHUD showErrorWithStatus:error.desc];
                                             }];
}
@end

